<?php //jQuery Validation ?>
<script type="text/javascript">
	$(document).ready(function(){
	     //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
     
        //Set height and width to mask to fill up the whole screen
        $('#loading').css({'width':maskWidth,'height':maskHeight,'position':'absolute','top':'0','left':'0','z-index':'1000'});

        $("#signup").click(function(e){
                    	
					$("#signup-form").validate();
					e.preventDefault;
					if($("#signup-form").valid()){ //register if form is valid
					    $("#signup").hide();
					    register($("#strBandName").val(),$("#strProfile").val(),$("#strLocation").val(),$("#strEmail").val(),$("#strContactNumber").val(),$("#strPass").val(),$("#con-password").val()); 
					
					}
		});
        
	});
		
		
	function register(_bandname,_about,_location,_email,_contactnumber,_password,_conpassword)
	{
		if(_password!=_conpassword)
		{
			$("#register-modal .modal-error").html("passwords do not match");
            $("#loading").hide();
			$("#signup").show();
			
		}
		else
		{
			$.post(base_url + "users/register/", {
				strName: _bandname,
				strProfile: _about,
				strLocation: _location,
				strEmail: _email,
				strContactNumber: _contactnumber,
				strPass: _password
				
			}, function(response){

					$("#loading").hide();
					$("#signup").show();
					$('span.modal-error').html(' ');
					$("span.modal-success").html(' ');
					var res = $.parseJSON(response);
					if(res.success==0 || res.success==2)
					{
						$("span.modal-error").html(res.message);
						$("#signup").show();
						$("#message-modal").modal('show');
					}
					else
					{
						//$("span.modal-error").html(' ');
						document.location = base_url +'users/confirm';
					}


				

			});

		}
		setTimeout("clear_html()","5000");
		return false;
	}		
	
	function clear_html()
	{
		//$("#message-modal").modal('close');
		$('span.modal-error').html('');
	}
</script>